import fr.storeme.android.tinywebdb.server.store.DataAI

// storvalue would parse tag=foo&value=bar and respond with ["STORED", "foo","bar"]

 
import java.util.ArrayList
import com.google.gson.Gson
import java.net.URLEncoder
import java.net.URL
import groovyx.gaelyk.logging.GroovyLogger

response.setContentType("application/jsonrequest")


 def tag = request.getParameter("tag")
 def value = request.getParameter("value")
 
log.info "tag :" +tag
String[] returnAR = new String[3];
Gson gson = new Gson();

returnAR[0] ="STORED"
returnAR[1] =tag
returnAR[2] = value
log.info "process :" +process( tag, value)
log.info "value :" +returnAR[2]
log.info "gson.toJson(returnAR) :" +gson.toJson(returnAR)

println gson.toJson(returnAR)

private String process(String tag,String value){
	DataAI data = new DataAI(tag,value);	return dao.ofy().put(data);
}